// ignore_for_file: prefer_const_constructors_in_immutables, prefer_const_constructors, prefer_const_literals_to_create_immutables

import 'package:flutter/material.dart';
import 'package:get/get.dart';

import 'controller.dart';
import 'second_index.dart';

class PutFindPage1 extends StatelessWidget {
  PutFindPage1({super.key});

  final controller = Get.put(firstController());
  
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title:Text("依赖注入 - Put_Find"),
      ),
      body: Center(
        child: Column(
          children: <Widget>[
            SizedBox(height: 14,),
            GetX<firstController>(
              init: controller,
              initState: (_) {
              },
              builder: (_) => Text("value -> ${_.count}",style: TextStyle(fontSize: 18),),
            ),
            SizedBox(height: 20,),
            ElevatedButton(onPressed: () => controller.add(), child:Text("add",style: TextStyle(fontSize: 18),)),
            SizedBox(height: 20,),
            ElevatedButton(onPressed: () =>Get.to(() => PutFindPage2()), child:Text("页面2自动同步",style: TextStyle(fontSize: 18),)),
          ],
        ),
      ),
    );
  }
}